import java.util.LinkedList ;
import java.util.Iterator;
import java.util.*;


public class linkedlistdemo {
	
	public static void main(String[] args) {
		LinkedList<Student> sl=new LinkedList<Student>();
		sl.add(new Student(10,"sachin"));
		sl.add(new Student(34,"praveen"));
		System.out.println("s size"+sl.size());
		Iterator it=sl.iterator();
		System.out.println("student list contain");
		while(it.hasNext()){
			System.out.println(it.next() +" ");
		}
		
		System.out.println("adding first location");
		sl.addFirst(new Student(23,"guru"));
		it=sl.iterator();
		while(it.hasNext()){
			System.out.println(it.next()+" ");
		}
		sl.removeFirst();
		it=sl.iterator();
		System.out.println("after removing");
		while(it.hasNext()){
			System.out.println(it.next()+" ");
		}
		/*sl.removeLast();
		it=sl.iterator();
		System.out.println("after removing");
		while(it.hasNext()){
			System.out.println(it.next()+" ");
		}*/
		System.out.println("adding 2nd locATION");
		sl.add(1,new Student(21,"hai"));
		it=sl.iterator();
		while(it.hasNext()){
			System.out.println(it.next()+" ");
		}
		

	}

}
